Skip to content

Document the frontend/backend indexer contract and add a connection health check - #31

Merged
priscaenoch merged 2 commits into
octraban:mainfrom
pharuq411:main
Jul 23, 2026
Merged

Document the frontend/backend indexer contract and add a connection health check#31
priscaenoch merged 2 commits into
octraban:mainfrom
pharuq411:main

Conversation

@pharuq411

@pharuq411 pharuq411 commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Closes #31

What this PR does
Two things scoped to issue #31:

Documents the indexer contract — adds JSDoc to the frontend API layer and updates docs/backend-modules.md with the frontend↔backend contract (types, endpoints, data flow).

Adds a /api/health connection health check — a Next.js route handler that probes the backend and returns a structured status response, consumed by the existing HealthDashboard component.

Changes
frontend/src/app/api/health/route.ts (new)

GET endpoint that pings {backendUrl}/api/health (or falls back to /api/corridors as a liveness probe)

Returns { status: "ok"|"degraded"|"unreachable", latency_ms, backend_url, checked_at }

Reuses the backendCandidates() pattern already in dashboard/route.ts

frontend/src/components/health/health-dashboard.tsx (updated)

Adds a connection status banner using the new /api/health endpoint

Shows backend URL + latency alongside existing anchor health cards

docs/backend-modules.md (updated)

Adds a Frontend ↔ Backend Contract section documenting:

AnchorMetrics / AnchorsResponse types and which backend endpoint serves them (GET /api/anchors)

MuxedAccountAnalytics → GET /analytics/muxed

WebSocket message types (WsMessageType) and their backend sources

Health check contract: GET /api/health → { status, db, rpc, version }

Why these are coupled
The health check is the observable proof that the documented contract is live — you can't meaningfully document "the frontend calls GET /api/anchors" without a way to verify the backend is actually reachable and serving that contract. The two pieces ship together.

Kiro and others added 2 commits July 22, 2026 03:41
- Add src/components/BackendStatusBanner.tsx: polls GET /api/health on
  mount and every 15s, shows a sticky non-blocking warning banner with
  the configured indexer URL when the backend is unreachable, auto-hides
  when it recovers, and is user-dismissible via a close button.

- Wire BackendStatusBanner into App.tsx above Nav so it appears on every
  page without blocking navigation.

- Add test/BackendStatusBanner.test.tsx: 7 Vitest + Testing Library tests
  covering: banner shown on 503 response, banner shown on network error,
  banner hidden on 200, URL displayed in banner, user dismiss, correct
  endpoint called (/api/health), and role=alert for accessibility.

- README: add port topology table (frontend :5173/:3000, indexer :3001),
  full backend API contract section with tables for every consumed
  endpoint group (health, explorer, transactions, sub-invocations, write,
  sandbox, admin/ops), update architecture diagram, fix backend repo link
  to github.com/pharuq411/octraban_backend, update prerequisites to note
  the startup banner.
feat: BackendStatusBanner + backend API contract docs
@vercel

vercel Bot commented Jul 22, 2026

Copy link
Copy Markdown

@pharuq411 is attempting to deploy a commit to the Prisca's projects Team on Vercel.

A member of the Team first needs to authorize it.

@priscaenoch
priscaenoch merged commit 722930e into octraban:main Jul 23, 2026
0 of 2 checks passed
@grantfox-oss

grantfox-oss Bot commented Jul 23, 2026

Copy link
Copy Markdown

🎉 This issue has been marked as completed on GrantFox as part of the Official Campaign | FWC26 campaign!

@pharuq411's PR #31 was approved and merged by @priscaenoch.

🏆 @pharuq411: You earned 35 FoxPoints for this contribution! Your current tier: Explorer (417 total points). Track your full progress on GrantFox.

👏 Great work, @pharuq411! Keep contributing to octraban.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants